package com.cw.DesignModel23.Structural.CompositePattern.Composite2;

import java.util.ArrayList;
import java.util.List;

//学院
public class College extends OrganizationComponent {

    /**
     * 存储系
     */
    List<OrganizationComponent> organizationComponents = new ArrayList<OrganizationComponent>();

    /**
     * 构造器
     * @param name
     * @param des
     */
    public College(String name, String des) {
        super(name, des);
    }

    @Override
    protected void add(OrganizationComponent organizationComponent) {
        // 将来实际业务中，Colleage 的 add 和  University add 不一定完全一样
        organizationComponents.add(organizationComponent);
    }

    @Override
    protected void remove(OrganizationComponent organizationComponent) {
        organizationComponents.remove(organizationComponent);
    }

    @Override
    public String getName() {
        return super.getName();
    }

    @Override
    public String getDes() {
        return super.getDes();
    }

    /**
     * print方法，就是输出学院包含的系
     */
    @Override
    protected void print() {
        System.out.println("--------------" + getName() + "--------------");
        // 遍历 organizationComponents
        for (OrganizationComponent organizationComponent : organizationComponents) {
            organizationComponent.print();
        }
    }


}

